#ifndef USERPERSONAL_UI_H
#define USERPERSONAL_UI_H

#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
#include<QLabel>
#include<QLineEdit>
#include "ip_port.h"
#include"PptpMessage.h"
#include"PptpClient.h"
class UserPersonal : public QWidget
{
    Q_OBJECT
public:
    explicit UserPersonal(QWidget *parent = nullptr);
    ~UserPersonal();

    void showPersonalInfo();
    QPushButton *personalInfoButton;
    QPushButton *addressManageButton;
    QPushButton *orderManageButton;
    PptpMessage requestMessage;
    PptpMessage responseMessage;
    PptpClient pptpclient;

    QLabel *avatarLabel;
    QLabel *nicknameLabel;  // Change QLineEdit to QLabel
    QLabel *genderLabel;    // Change QLineEdit to QLabel
    QLabel *signLabel;      // Change QLineEdit to QLabel
    QLabel *emailLabel;     // Change QLineEdit to QLabel
    struct OrderLabels {
        QLabel *labelOrderIDValue;
        QLabel *labelCreateTimeValue;
        QLabel *labelRecipientNameValue;
        QLabel *labelRecipientPhoneValue;
        QLabel *labelAddressValue;
        QLabel *labelTotalPriceValue;
        QLabel *labelProductNameValue;
        QLabel *labelQuantityValue;
        QLabel *labelUnitPriceValue;
        QLabel *productImageLabel;
    };

    QList<OrderLabels*> orderLabels;

    QPushButton *editButton;
    QLabel *label12;
    QWidget *orderManageWidget;
    QVBoxLayout *orderLayout;
    QString buttonStyle();
    void fetchOrderList();
    void displayOrderDetails(int index, int orderId, const QString &orderDate, double totalAmount, const QString &recipientName, const QString &recipientPhone, const QString &shippingAddress);
    void displayProductDetails(int index, int quantity, double unitPrice);
    void setProductDetails(int index, const QString &productName, const QPixmap &productImage);

private:

    void init();
    void setUpSplitter();
    void showPersonalInfo(QVBoxLayout *infoLayout);
    void createOrderLayout(QVBoxLayout *orderLayout);

    void fetchProductDetails(int productId);

private slots:
    void onOrderListResponse(PptpMessage responseMessage);
    void onProductDetailsResponse(PptpMessage responseMessage);




};


#endif // USERPERSONAL_UI_H
